package cn.kgm.makeGod;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @Version 1.8
 * @Author: Kappi
 * @Date: 2025-9-11 17:54
 * @Description: cn.kgm.makeGod.ResourceNode
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ResourceNode {
    private int id;
    private String name;
    private Location location;
    private int itemId; // 产出的物品ID
    private int respawnTime; // 重生时间（月）
    private int currentTime; // 当前时间（月）
    private boolean available; // 是否可用

    public ResourceNode(int id, String name, Location location, int itemId, int respawnTime) {
        this.id = id;
        this.name = name;
        this.location = location;
        this.itemId = itemId;
        this.respawnTime = respawnTime;
        this.currentTime = 0;
        this.available = true;
    }

    // 更新时间
    public void update() {
        if (!available) {
            currentTime++;
            if (currentTime >= respawnTime) {
                available = true;
                currentTime = 0;
            }
        }
    }

    // 获取资源
    public boolean harvest() {
        if (available) {
            available = false;
            return true;
        }
        return false;
    }

    // getter和setter方法
    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public Location getLocation() {
        return location;
    }

    public int getItemId() {
        return itemId;
    }

    public boolean isAvailable() {
        return available;
    }
}
